<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/jsp/common/common.jsp"%>
<%
	String m = request.getParameter("m");
//System.out.println("m=="+m);
request.setAttribute("m",m);
	session.setAttribute("m", m);
	String qxbtn = request.getParameter("qxbtn");
	//System.out.println("qxbtn=="+qxbtn);
	request.setAttribute("qxbtn",qxbtn);
		session.setAttribute("qxbtn", qxbtn);
		String con20 = request.getParameter("searchBean.con20");
		String con6 = request.getParameter("searchBean.con6");
		String countPerPage = request.getParameter("countPerPage");
		String url = request.getParameter("url");
//System.out.println("con20=="+con20);
%>
<HTML>
	<HEAD>
			<script type="text/javascript">   
			var tabPanel;
			Ext.onReady(function(){  
			    // 主面板（已有tab）   	
			     tabPanel = new Ext.TabPanel({   
			        region:'center',   
			        deferredRender:false,   
			        autoScroll: true,    
			        margins:'0 0 0 0',   
			        activeTab:0,   
			        
			        //下面是比上面例子新增的关键右键菜单代码
			        listeners:{
			                 //传进去的三个参数分别为:这个tabpanel(tabsDemo),当前标签页,事件对象e
			                "contextmenu":function(tdemo,myitem,e){
			                            menu=new Ext.menu.Menu([{
			                                     text:"关闭当前页",
			                                     handler:function(){
			                                        
			                                        if(myitem.id!='list_tabPanel'){
			                                          tdemo.remove(myitem);
			                                        }
			                                        
			                                     }
			                            },{
			                                     text:"关闭其他所有页",
			                                     handler:function(){
			                                        //循环遍历
			                                        tdemo.items.each(function(item){
			                                             if(item.closable&&item!=myitem)
			                                             {
			                                                //可以关闭的其他所有标签页全部关掉
			                                                tdemo.remove(item);
			                                             }
			                                        });
			                                     }
			                            }]);
			                            //显示在当前位置
			                            menu.showAt(e.getPoint());
			                 }
			        },
			        
			
			        items:[{   
			            id:'list_tabPanel',   
			            contentEl:'tabs',   
			            title: '记录列表一览',   
			            closable:false,   
			            autoScroll:true,
			          html:'<div scrolling="no" style= "overflow:hidden"><iframe id="list_frame" src= "<%=contextPath%>/<%=url%>?searchBean.con20=<%=con20%>&searchBean.con6=<%=con6%>&countPerPage=<%=countPerPage%>&qxbtn=<%=qxbtn%>&m=<%=m%>"  width="100%" height="100%" frameborder="0" scrolling="yes" style="overflow-x:scroll"></iframe></div>'  	   
			        
			        }]      
			    });   
			
			    //===========================================
			    //  配置视图viewport   
			    viewport = new Ext.Viewport({   
			           layout:'border',   
			           items:[tabPanel]});   
		
			    // 映射连接的id到函数   
			    var count = 0;   
			    var actions = {   
			        'create' : function(){   
			            addTab("New Tab",'loripsum.html');   
			        },   
			        'use' : function(){  
			        //window.alert("count=="+count); 
			            // 演示页之间的轮换   
			            updateTab('tab1','替换' + count + ' 次','sample'+(count%2)+'.html');   
			            count++;                   
			        }   
			    };   
			    
			    function doAction(e, t){   
			        e.stopEvent();   
			        actions[t.id]();   
			    } 
			});    
			
			   // 在中间的面板加入tab   
			    function addTab(tabTitle, targetUrl, tab_num){   

			        var idstr = 'detail_tabPanel'+ tab_num;

					// 如果不存在新建一个, 如果存在让这个tab激活
			        if (tabPanel.getItem(idstr) == null || tabPanel.getItem(idstr) == undefined) {
			         
				        tabPanel.add({   
					        id:idstr,   
					        title: tabTitle,   
					        iconCls: 'tabs',   
					        //autoLoad: {url: targetUrl, callback: this.initSearch, scope: this},   
					        html:'<div scrolling="no" style= "overflow:hidden"><iframe src="'+targetUrl+'" width="100%" height="100%" frameborder="0" scrolling="yes"></iframe></div>',  
					        closable:true  
				       }).show();   

			        } else {
			            var tempTab = tabPanel.getItem(idstr);
			        	tabPanel.setActiveTab(tempTab);
			        }
			    }
			    
			    // 更新tab内容，如不存在就新建一个   
			    function updateTab(tabId,title, url) { 
			        var tab = tabPanel.getItem(tabId); 
			         window.alert(tab.id);    
			        if(tab){   
			            tab.getUpdater().update(url);   
			            tab.setTitle(title);   
			        }else{   
			            tab = addTab(title,url);   
			        }   
			        tabPanel.setActiveTab(tab);   
			    } 

			    // 删除Tab 
			    function deleteTab(tabId) { 
			    	 var tab = tabPanel.getItem(tabId); 
			    	 tabPanel.remove(tab); 
			    }   
		</script>  
		</HEAD>

<body class="standard" topmargin="0" leftmargin="0"> 
    
<ul id="actions" class="x-hidden">   
    <li>   
        <a id="use" href="#">Use Existing Tab</a>   
    </li>   
    <li>   
        <a id="create" href="#">Create New Tab</a>   
    </li>   
</ul>   
    
<div id="tabs"></div>   
</body>   
</html>  